package com.share.tool.devops.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.tool.devops.dao.HttpUrlConfigMapper;
import com.share.tool.devops.model.po.HttpUrlConfig;
import com.share.tool.devops.model.req.HttpUrlConfigListReq;
import com.share.tool.devops.service.HttpUrlConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HttpUrlConfigServiceImpl extends ServiceImpl<HttpUrlConfigMapper, HttpUrlConfig> implements HttpUrlConfigService {

    @Override
    public List<HttpUrlConfig> listConfig(HttpUrlConfigListReq req) {
        if (req == null) {
            req = new HttpUrlConfigListReq();
        }

        QueryWrapper wrapper = new QueryWrapper();
        if (StringUtils.isNotEmpty(req.getGCode())) {
            wrapper.eq("g_code", req.getGCode());
        }

        wrapper.eq("status", 1);/*有效的*/

        return this.baseMapper.selectList(wrapper);
    }
}
